/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package parismetro;

import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.image.Image;
import javafx.scene.CustomNode;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.input.MouseEvent;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.TextAlignment;
import java.text.DecimalFormat;
import javafx.scene.input.KeyEvent;
import javafx.scene.CacheHint;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;

/**
 * @author Hadrien
 */
public class Paiement extends CustomNode {

    var group: Group;
    public function timer() :Void {
            Timeline {
                repeatCount: 1
                keyFrames: [
                    KeyFrame {
                        time: 1150ms;
                        action: function() {
                            main.changeContent("merci");
                        } }]
            }.play();
    }
    public var main: Main;
    def backGround = ImageView {
                image: Image { url: "{__DIR__}icons/back_2-3.png" }
            //layoutX:0
            //layoutY:0
            }
    var cart = Cart {
                orderList: main.orderList;
                layoutX: 5
                layoutY: 5
            }
    def bouton_annuler_tout = Group {
                layoutX: 10;
                layoutY: 644;
                //effect: shadow;
                content: [
                    Rectangle {
                        height: 95
                        width: 100
                        arcWidth: 15, arcHeight: 15
                        fill: Color.rgb(255, 115, 89)
                        stroke: Color.WHITE;
                        strokeWidth: 5;
                    }
                    Text {
                        layoutX: 10, layoutY: 40
                        font: Font { size: 22, embolden: true, name: "Myriad Pro" }
                        content: "Annuler\nTout"
                        textAlignment: TextAlignment.CENTER
                        fill: Color.WHITE
                    }
                ]
                onMousePressed: function(e: MouseEvent): Void {
                    main.orderList.removeAll();
                    main.changeContent("accueil");
                }
            }
    def bouton_etape_prec = Group {
                layoutX: 120;
                layoutY: 644;
                //effect: shadow;
                content: [
                    Rectangle {
                        height: 95
                        width: 102
                        arcWidth: 15, arcHeight: 15
                        fill: Color.rgb(0, 113, 188)
                        stroke: Color.WHITE;
                        strokeWidth: 5;
                    }
                    Text {
                        layoutX: 1, layoutY: 40
                        font: Font { size: 19, embolden: true, name: "Myriad Pro" }
                        content: "Etape\nPrécédente"
                        textAlignment: TextAlignment.CENTER
                        fill: Color.WHITE
                    }
                ]
                onMousePressed: function(e: MouseEvent): Void {
                    main.changeContent(main.optionEcran.previousStep2);
                }
            }
    def bouton_autres_tickets = Group {
                layoutX: 5;
                layoutY: 540;
                //effect: shadow;
                content: [
                    Rectangle {
                        height: 100
                        width: 220
                        arcWidth: 20, arcHeight: 20
                        fill: Color.rgb(0, 113, 188)
                        stroke: Color.WHITE;
                        strokeWidth: 5;
                    }
                    Text {
                        layoutX: 10, layoutY: 40
                        //wrappingWidth:200
                        font: Font { size: 28, embolden: true, name: "Myriad Pro" }
                        content: "Acheter d'autres\nTickets"
                        textAlignment: TextAlignment.CENTER
                        fill: Color.WHITE
                    }
                ]
                onMousePressed: function(e: MouseEvent): Void {
                    main.changeContent("accueil");
                }
            }
    def txtResteAPayer = Text {
                font: Font { size: 48, embolden: true, name: "Myriad Pro" }
                x: 320, y: 90
                content: "Reste à payer : "
                onMouseClicked: function(e: MouseEvent): Void {
                    main.changeContent("merci");
                }
            }
    def nbResteAPayer = Text {
                font: Font { size: 48, embolden: true, name: "Myriad Pro" }
                x: 720, y: 90
                content: bind "{new DecimalFormat("0.00").format(Main.orderList.total)} €"
            }
    def txtCarte = Text {
                font: Font { size: 38, embolden: true, name: "Myriad Pro" }
                x: 687, y: 207
                content: "Cartes acceptées"
            }
    def txtMonnaie = Text {
                font: Font { size: 26, embolden: true, name: "Myriad Pro" };
                x: 686, y: 435;
                content: "Billets et pièces acceptés";
            }
    def indication = Text {
                font: Font { size: 26, embolden: true, name: "Myriad Pro" };
                x: 250, y: 160
                content: "Veuillez insérer votre carte bancaire\nOU des pièces et billets";
                fill: Color.RED
                textAlignment: TextAlignment.CENTER
            }

    override public function create(): Node {
        group = Group { content: [
                        backGround, indication, cart, bouton_annuler_tout, bouton_etape_prec, bouton_autres_tickets, txtResteAPayer, nbResteAPayer, txtMonnaie, txtCarte
                    ]
                    cache:true;
                    cacheHint: CacheHint.SPEED;
                }
        return group;
    }

}
